﻿/* Copyright 2012 Sannel Software, L.L.C.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at

 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
using System;
using System.Collections.Generic;
using System.Text;

namespace Sannel.Calculate.Nodes.Numbers
{
	/// <summary>
	/// Represents an Int32
	/// </summary>
	public class Int32Node : BaseNumber<Int32>
	{
		/// <summary>
		/// always returns TypeCode.Int32
		/// </summary>
		public override TypeCode NumberType
		{
			get { return TypeCode.Int32; }
		}

		/// <summary>
		/// Creates a new Int32Node
		/// </summary>
		public Int32Node()
		{
		}

		/// <summary>
		/// Create a new Int32Node with the provided number
		/// </summary>
		/// <param name="value"></param>
		public Int32Node(Int32 value)
		{
			Value = value;
		}

		/// <summary>
		/// Copies this node minuse its links
		/// </summary>
		/// <returns></returns>
		public override BaseNode Copy()
		{
			return new Int32Node(Value);
		}

		/// <summary>
		/// Calls out to Convert.ToByte on the Value
		/// </summary>
		/// <returns></returns>
		public override byte ToByte()
		{
			return Convert.ToByte(Value);
		}

		/// <summary>
		/// Calls out to Convert.ToInt16 on the Value
		/// </summary>
		/// <returns></returns>
		public override short ToInt16()
		{
			return Convert.ToInt16(Value);
		}

		/// <summary>
		/// Returns the Value;
		/// </summary>
		/// <returns></returns>
		public override int ToInt32()
		{
			return Value;
		}

		/// <summary>
		/// Returns the Value;
		/// </summary>
		/// <returns></returns>
		public override long ToInt64()
		{
			return Value;
		}

		/// <summary>
		/// Returns the Value;
		/// </summary>
		/// <returns></returns>
		public override float ToSingle()
		{
			return Value;
		}

		/// <summary>
		/// Returns the Value;
		/// </summary>
		/// <returns></returns>
		public override double ToDouble()
		{
			return Value;
		}

		/// <summary>
		/// Returns the Value
		/// </summary>
		/// <returns></returns>
		public override decimal ToDecimal()
		{
			return Value;
		}
	}
}
